import 'package:flutter/material.dart';
import 'package:fly_car/search_bar_delegate.dart';

import 'login.dart';
import 'main_page.dart';
import 'message.dart';

final routes = {
  '/login': (context) => LoginPage(),
  '/main': (context) => MainPage(),
  '/message': (context) => MessagePage(),
  '/search': (context, {arguments}) => SearchPage(arguments: arguments),
  // '/form':(context)=>FormPage(),'/search':(context,{arguments})=>SearchPage(arguments:arguments),
};

//固定写法
var onGenerateRoute = (RouteSettings settings) {
  // 统一处理
  final String name = settings.name;
  final Function pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments),
          settings: RouteSettings(arguments: settings.arguments));
      return route;
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};
